//
//  ContentView.swift
//  SwiftUIDemo
//
//  Created by Tilt Wang on 2025/6/25.
//

import SwiftUI

struct ContentView: View {
    
    @State var models: [DisplayModel] = [
        DisplayModel.init(name: "2 Text 文本 TextDemo", view: TextDemo())
    ]
    
    var body: some View {
        NavigationView() {
            List() {
//                ForEach(models, id: \.self) { model in
//                    NavigationLink(destination: Text(model.name), label: model.view)
//                }
//                ForEach(models) { model in
//                    NavigationLink(destination: Text(model.name), label: model.view)
//                }
                
                NavigationLink("2 Text 文本 TextDemo") {
                    TextDemo()
                }
                NavigationLink("3 Shape 形状 ShapeDemo") {
                    ShapeDemo()
                }
                NavigationLink("4 Color 颜色 ColorDemo") {
                    ColorDemo()
                }
                NavigationLink("5 Gradient 渐变色 GradientsDemo") {
                    GradientsDemo()
                }
                NavigationLink("6 Icons 图标 IconsDemo") {
                    IconsDemo()
                }
                NavigationLink("7 Image 图片 ImageDemo") {
                    ImageDemo()
                }
                NavigationLink("8 Frame 框架 FrameDemo") {
                    FrameDemo()
                }
                NavigationLink("9 Background and OverLays  背景 BackgroundAndOverlayDemo") {
                    BackgroundAndOverlayDemo()
                }
                NavigationLink("10 Stack 布局 StackDemo") {
                    StackDemo()
                }
                NavigationLink("11 Padding 间隔 PaddingDemo") {
                    PaddingDemo()
                }
                NavigationLink("12 Spacer 空间占位 SpacerDemo") {
                    SpacerDemo()
                }
                NavigationLink("13 init & enums 初始化和枚举 InitializerDemo") {
                    InitializerDemo(count: 55, fruit: .orange)
                }
                NavigationLink("14 ForEach 循环 ForEachDemo") {
                    ForEachDemo()
                }
                NavigationLink("15 ScrollView 滚动视图 ScrollViewDemo") {
                    ScrollViewDemo()
                }
                NavigationLink("16 Grid 网格视图 GridDemo") {
                    GridDemo()
                }
                NavigationLink("17 SafeArea 安全区域 SafeAreaDemo") {
                    SafeAreaDemo()
                }
                NavigationLink("18 Button 按钮 ButtonDemo") {
                    ButtonDemo()
                }
                NavigationLink("19 @State 状态包装器 StateDemo") {
                    StateDemo()
                }
                NavigationLink("20 Extract Function & Views 外部方法 ExtractedFunctionDemo") {
                    ExtractedFunctionDemo()
                }
                NavigationLink("21 Extract Subview 外部视图 ExtractSubviewDemo") {
                    ExtractSubviewDemo()
                }
                NavigationLink("22 @Binding 属性包装器 BindingDemo") {
                    BindingDemo()
                }
                NavigationLink("23 Conditional Statements 条件语句 ConditionalDemo") {
                    ConditionalDemo()
                }
                NavigationLink("24 TernaryDemo 三元运算符 TernaryDemo") {
                    TernaryDemo()
                }
                NavigationLink("25 Animation 动画 AnimationDemo") {
                    AnimationDemo()
                }
                NavigationLink("26 Animation Curves 动画曲线 AnimationTimingDemo") {
                    AnimationTimingDemo()
                }
                NavigationLink("27 Transition 过渡动画 TranstionDemo") {
                    TextDemo()
                }
                NavigationLink("28 Sheet & fullScreenCover 页面转场 SheetDemo") {
                    SheetDemo()
                }
                NavigationLink("29 Popover  复习 几种转场方式 sheet transion offset等 PopoverDemo") {
                    PopoverDemo()
                }
                NavigationLink("30 NavigationView & NavigationLink 导航试图 NavigationViewDemo") {
                    NavigationViewDemo()
                }
                NavigationLink("31 List 列表 ListDemo") {
                    ListDemo()
                }
                NavigationLink("32 Alert 弹框 AlertDemo") {
                    AlertDemo()
                }
                NavigationLink("33 ActionSheet 操作弹框 ActionSheetDemo") {
                    ActionSheetDemo()
                }
                NavigationLink("34 ContextMenu 上下文菜单 ContextMenuDemo") {
                    ContextMenuDemo()
                }
                NavigationLink("35 TextField 输入框 TextFieldDemo") {
                    TextFieldDemo()
                }
                NavigationLink("36 TextEditor 文本编辑器 TextEditorDemo") {
                    TextEditorDemo()
                }
                NavigationLink("37 Toggle 切换开关 ToggleDemo") {
                    ToggleDemo()
                }
                NavigationLink("38 Picker 选择器 PickerDemo") {
                    PickerDemo()
                }
                NavigationLink("39 ColorPicker 颜色选择器 ColorPickerDemo") {
                    ColorPickerDemo()
                }
                NavigationLink("40 DatePicker 日期选择器 DatePickerDemo") {
                    DatePickerDemo()
                }
                NavigationLink("41 Stepper 步进器 StepperDemo") {
                    StepperDemo()
                }
                NavigationLink("42 Slider 滑块 SliderDemo") {
                    SliderDemo()
                }
                NavigationLink("43 TabView & PageTabViewStyle 标签页面 TabViewDemo") {
                    TabViewDemo()
                }
                NavigationLink("44 DarkMode 深色模式 DarkModeDemo") {
                    DarkModeDemo()
                }
                NavigationLink("45 Markups & Documentation 代码注释和文档说明 DocumentationDemo") {
                    DocumentationDemo()
                }
                NavigationLink("46 didAppear & didDisappear 状态方法调用 OnAppearDemo") {
                    OnAppearDemo()
                }
                NavigationLink("47 if let & guard statements 安全编码 IfLetGuardDemo") {
                    IfLetGuardDemo()
                }
                NavigationLink("48 Tap Gesture 点击手势 TapGestureDemo") {
                    TapGestureDemo()
                }
                NavigationLink("49 Custom Data Types (Structs) 自定义类型 ModelDemo") {
                    ModelDemo()
                }
                NavigationLink("50 StateObject & @ObservableObject 属性包装器 ViewModelDemo") {
                    ViewModelDemo()
                }
                NavigationLink("51 @EnvironmentObject 环境对象 EnvironmentObjectDemo") {
                    EnvironmentObjectDemo()
                }
                NavigationLink("52 @AppStorage 应用默认存储 偏好设置 AppStorageDemo") {
                    AppStorageDemo()
                }
                //
                //
                
            }
            .navigationTitle("学习速览")
        }
    }
    
    //2 Text 文本 TextDemo
    //3 Shape 形状 ShapeDemo
    //4 Color 颜色 ColorDemo
    //5 Gradient 渐变色 GradientDemo
    //6 Icons 图标 IconsDemo
    //7 Image 图片 ImageDemo
    //8 Frame 框架 FrameDemo
    //9 Background and OverLays  背景//fixme OverLays  BackgroundAndOverlayDemo
    //10 Stack 布局 StackDemo
    //11 Padding 间隔 PaddingDemo
    //12 Spacer 空间占位 SpacerDemo
    //13 init & enums 初始化和枚举 InitializerDemo
    //14 ForEach 循环 ForEachDemo
    //15 ScrollView 滚动视图 ScrollViewDemo
    //16 Grid 网格视图 GridDemo
    //17 SafeArea 安全区域 SafeAreaDemo
    //18 Button 按钮 ButtonDemo
    //19 @State 状态包装器 StateDemo
    //20 Extract Function & Views 外部方法 ExtractedFunctionDemo
    //21 Extract Subview 外部视图 ExtractSubviewDemo
    //22 @Binding 属性包装器 BindingDemo
    //23 Conditional Statements 条件语句 ConditionalDemo
    //24 TernaryDemo 三元运算符 TernaryDemo
    //25 Animation 动画 AnimationDemo
    //26 Animation Curves 动画曲线 AnimationTimingDemo
    //27 Transition 过渡动画 TranstionDemo
    //28 Sheet & fullScreenCover 页面转场 SheetDemo
    //29 Popover  复习 几种转场方式 sheet transion offset等 PopoverDemo
    //30 NavigationView & NavigationLink 导航试图 NavigationViewDemo
    //31 List 列表 ListDemo
    //32 Alert 弹框 AlertDemo
    //33 ActionSheet 操作弹框 ActionSheetDemo
    //34 ContextMenu 上下文菜单 ContextMenuDemo
    //35 TextField 输入框 TextFieldDemo
    //36 TextEditor 文本编辑器 TextEditorDemo
    //37 Toggle 切换开关 ToggleDemo
    //38 Picker 选择器 PickerDemo
    //39 ColorPicker 颜色选择器 ColorPickerDemo
    //40 DatePicker 日期选择器 DatePickerDemo
    //41 Stepper 步进器 StepperDemo
    //42 Slider 滑块 SliderDemo
    //43 TabView & PageTabViewStyle 标签页面 TabViewDemo
    //44 DarkMode 深色模式 DarkModeDemo
    //45 Markups & Documentation 代码注释和文档说明 DocumentationDemo
    //46 onAppear & onDisappear 状态方法调用 OnAppearDemo
    //47 if let & guard statements 安全编码 IfLetGuardDemo
    //48 Tap Gesture 点击手势 TapGestureDemo
    //49 Custom Data Types (Structs) 自定义类型 ModelDemo
    //50 StateObject & @ObservableObject 属性包装器 ViewModelDemo
    //51 @EnvironmentObject 环境对象 EnvironmentObjectDemo
    //52 @AppStorage 应用默认存储 偏好设置 AppStorageDemo
}

struct DisplayModel {
    var name: String
    var view: any View
    init(name: String, view: any View) {
        self.name = name
        self.view = view
    }
}

#Preview {
    ContentView()
}
